package org.come.login;

import org.come.entity.RegionResult;
import org.come.until.MessagrFlagUntil;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;
import java.util.stream.Collectors;

public class MainMouslisten implements MouseListener {
    private Integer i;
    private SpriteBtn btn;
    private LoginJpanel loginJpanel;

    public MainMouslisten(int i, SpriteBtn btn, LoginJpanel loginJpanel) {
        this.i = i;
        this.btn = btn;
        this.loginJpanel = loginJpanel;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
    }

    @Override
    public void mousePressed(MouseEvent e) {
        this.btn.btn(2);
        switch (this.i) {
            case 1:
                // 游戏开始界面
                // MainView mainView = this.loginJpanel.getMainView();
                // this.loginJpanel.setMainY(mainView.getY());
                // 开始选区界面
                AreaView areaView = this.loginJpanel.getAreaView();
                this.loginJpanel.setMainY(areaView.getY());

                this.loginJpanel.framechange(1, this.loginJpanel.getRegionResultList(), null);
                this.loginJpanel.setInterfaceScrolling(true);
            case 2:
            case 3:
            case 4:
            default:
                break;
            case 5:
                System.exit(1);
                break;
            case 1000:
                this.loginJpanel.getAreaView().drawSectors(this.loginJpanel.getAreaView().getRegionResultList(), this.loginJpanel);
                break;
            case 1001:
            case 1002:
            case 1003:
            case 1004:
                List<RegionResult> regionResultList = this.loginJpanel.getAreaView().getRegionResultList();
                List<RegionResult> collect = (List) regionResultList.stream().filter((item) -> {
                    return item.getOT_BELONG().toString().equals(this.i.toString());
                }).collect(Collectors.toList());
                this.loginJpanel.getAreaView().drawSectors(collect, this.loginJpanel);
        }

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        this.btn.btn(0);
        if (this.i == 99) {
            this.loginJpanel.framechange(5, null, null);
        } else if (this.i == 100) {
            this.loginJpanel.framechange(0, null, null);
        }

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
        if (this.btn.getZhen() != 2) {
            this.btn.btn(1);
        }

    }

    @Override
    public void mouseExited(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        if (this.btn.getZhen() != 2) {
            this.btn.btn(0);
        }

    }
}
